package com.ybxx.fees.model;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.StringUtils;

import com.ybxx.base.model.Residents;
import com.ybxx.base.model.Room;
import com.ybxx.base.model.Rule;
import com.ybxx.core.model.BaseModel;

@Entity
@Table(name="tbl_fees_records")
public class Records extends BaseModel {
	@Id
	private String frcode;
	@ManyToOne(targetEntity=Room.class,fetch=FetchType.LAZY)
	@JoinColumn(name="rid",referencedColumnName="rid") 
	private Room room;
	@ManyToOne(targetEntity=Residents.class,fetch=FetchType.LAZY)
	@JoinColumn(name="rcode",referencedColumnName="rcode") 
	private Residents residents;
	private String ymonth;
	private String bfees;
	private String warrearage;
	private String shouldpay;
	private String realpay;
	private String barrearage;
	private String state;
	private String content;
	private String jtime;
	private String charge;
	private String pname;
	
	@OneToMany(targetEntity=OtherRecord.class,cascade={CascadeType.ALL},mappedBy="records",fetch = FetchType.LAZY)
	private Set<OtherRecord> otherRecords=new HashSet<OtherRecord>();
	@OneToMany(targetEntity=FfRecord.class,cascade={CascadeType.ALL},mappedBy="records",fetch = FetchType.LAZY)
	private Set<FfRecord> ffRecords=new HashSet<FfRecord>();
	@OneToMany(targetEntity=NqfRecord.class,cascade={CascadeType.ALL},mappedBy="records",fetch = FetchType.LAZY)
	private Set<NqfRecord> nqfRecords=new HashSet<NqfRecord>();
	@OneToMany(targetEntity=GlfRecord.class,cascade={CascadeType.ALL},mappedBy="records",fetch = FetchType.LAZY)
	private Set<GlfRecord> glfRecords=new HashSet<GlfRecord>();
	@OneToMany(targetEntity=AnmeterRecords.class,cascade={CascadeType.ALL},mappedBy="records",fetch = FetchType.LAZY)
	private Set<AnmeterRecords> anmeterRecords=new HashSet<AnmeterRecords>();
	@OneToMany(targetEntity=WatermeterRecords.class,cascade={CascadeType.ALL},mappedBy="records",fetch = FetchType.LAZY)
	private Set<WatermeterRecords> watermeterRecords=new HashSet<WatermeterRecords>();
	@OneToMany(targetEntity=WsfRecord.class,cascade={CascadeType.ALL},mappedBy="records",fetch = FetchType.LAZY)
	private Set<WsfRecord> wsfRecords=new HashSet<WsfRecord>();
	@OneToMany(targetEntity=HlfRecord.class,cascade={CascadeType.ALL},mappedBy="records",fetch = FetchType.LAZY)
	private Set<HlfRecord> hlfRecords=new HashSet<HlfRecord>();
	@Transient
	private AnmeterRecords anmeterRecord;
	@Transient
	private WatermeterRecords watermeterRecord;
	@Transient
	private WsfRecord wsfRecord;
	@Transient
	private HlfRecord hlfRecord;
	@Transient
	private GlfRecord glfRecord;
	@Transient
	private NqfRecord nqfRecord;
	@Transient
	private OtherRecord otherRecord;
	@Transient
	private FfRecord ffRecord;
	public String getFrcode() {
		return frcode;
	}
	public void setFrcode(String frcode) {
		this.frcode = frcode;
	}
	public Room getRoom() {
		return room;
	}
	public void setRoom(Room room) {
		this.room = room;
	}
	public Residents getResidents() {
		return residents;
	}
	public void setResidents(Residents residents) {
		this.residents = residents;
	}
	public String getYmonth() {
		return ymonth;
	}
	public void setYmonth(String ymonth) {
		this.ymonth = ymonth;
	}
	public String getBfees() {
		if(StringUtils.isNotEmpty(bfees)){
			return bfees;
		}else{
			return "0";
		}
	}
	public void setBfees(String bfees) {
		this.bfees = bfees;
	}
	public String getWarrearage() {
		return warrearage;
	}
	public void setWarrearage(String warrearage) {
		if(StringUtils.isEmpty(warrearage)){
			this.warrearage = "0";
		}else{
			this.warrearage = warrearage;
		}
	}
	public String getShouldpay() {
		return shouldpay;
	}
	public void setShouldpay(String shouldpay) {
		if(StringUtils.isEmpty(shouldpay)){
			this.shouldpay = "0";
		}else{
			this.shouldpay = shouldpay;
		}
	}
	public String getRealpay() {
		return realpay;
	}
	public void setRealpay(String realpay) {
		this.realpay = realpay;
	}
	public String getBarrearage() {
		return barrearage;
	}
	public void setBarrearage(String barrearage) {
		this.barrearage = barrearage;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getJtime() {
		return jtime;
	}
	public void setJtime(String jtime) {
		this.jtime = jtime;
	}
	public String getCharge() {
		return charge;
	}
	public void setCharge(String charge) {
		this.charge = charge;
	}
	public Set<OtherRecord> getOtherRecords() {
		return otherRecords;
	}
	public void setOtherRecords(Set<OtherRecord> otherRecords) {
		this.otherRecords = otherRecords;
	}
	public Set<FfRecord> getFfRecords() {
		return ffRecords;
	}
	public void setFfRecords(Set<FfRecord> ffRecords) {
		this.ffRecords = ffRecords;
	}
	public Set<NqfRecord> getNqfRecords() {
		return nqfRecords;
	}
	public void setNqfRecords(Set<NqfRecord> nqfRecords) {
		this.nqfRecords = nqfRecords;
	}
	public Set<GlfRecord> getGlfRecords() {
		return glfRecords;
	}
	public void setGlfRecords(Set<GlfRecord> glfRecords) {
		this.glfRecords = glfRecords;
	}
	public Set<AnmeterRecords> getAnmeterRecords() {
		return anmeterRecords;
	}
	public void setAnmeterRecords(Set<AnmeterRecords> anmeterRecords) {
		this.anmeterRecords = anmeterRecords;
	}
	public Set<WatermeterRecords> getWatermeterRecords() {
		return watermeterRecords;
	}
	public void setWatermeterRecords(Set<WatermeterRecords> watermeterRecords) {
		this.watermeterRecords = watermeterRecords;
	}
	public Set<WsfRecord> getWsfRecords() {
		return wsfRecords;
	}
	public void setWsfRecords(Set<WsfRecord> wsfRecords) {
		this.wsfRecords = wsfRecords;
	}
	public Set<HlfRecord> getHlfRecords() {
		return hlfRecords;
	}
	public void setHlfRecords(Set<HlfRecord> hlfRecords) {
		this.hlfRecords = hlfRecords;
	}
	public AnmeterRecords getAnmeterRecord() {
		if(anmeterRecords!=null){
			for(Iterator<AnmeterRecords> iter=anmeterRecords.iterator();iter.hasNext();){
				anmeterRecord=iter.next();
				break;
			}
		}
		return anmeterRecord;
	}
	public WatermeterRecords getWatermeterRecord() {
		if(watermeterRecords!=null){
			for(Iterator<WatermeterRecords> iter=watermeterRecords.iterator();iter.hasNext();){
				watermeterRecord=iter.next();
				break;
			}
		}
		return watermeterRecord;
	}
	public WsfRecord getWsfRecord() {
		if(wsfRecords!=null){
			for(Iterator<WsfRecord> iter=wsfRecords.iterator();iter.hasNext();){
				wsfRecord=iter.next();
				break;
			}
		}
		return wsfRecord;
	}
	public HlfRecord getHlfRecord() {
		if(hlfRecords!=null){
			for(Iterator<HlfRecord> iter=hlfRecords.iterator();iter.hasNext();){
				hlfRecord=iter.next();
				break;
			}
		}
		return hlfRecord;
	}
	public GlfRecord getGlfRecord() {
		if(glfRecords!=null){
			for(Iterator<GlfRecord> iter=glfRecords.iterator();iter.hasNext();){
				glfRecord=iter.next();
				break;
			}
		}
		return glfRecord;
	}
	public NqfRecord getNqfRecord() {
		if(nqfRecords!=null){
			for(Iterator<NqfRecord> iter=nqfRecords.iterator();iter.hasNext();){
				nqfRecord=iter.next();
				break;
			}
		}
		return nqfRecord;
	}
	public OtherRecord getOtherRecord() {
		if(otherRecords!=null){
			for(Iterator<OtherRecord> iter=otherRecords.iterator();iter.hasNext();){
				otherRecord=iter.next();
				break;
			}
		}
		return otherRecord;
	}
	public FfRecord getFfRecord() {
		if(ffRecords!=null){
			for(Iterator<FfRecord> iter=ffRecords.iterator();iter.hasNext();){
				ffRecord=iter.next();
				break;
			}
		}
		return ffRecord;
	}
	public void setAnmeterRecord(AnmeterRecords anmeterRecord) {
		this.anmeterRecords.add(anmeterRecord);
		this.anmeterRecord = anmeterRecord;
	}
	public void setWatermeterRecord(WatermeterRecords watermeterRecord) {
		this.watermeterRecords.add(watermeterRecord);
		this.watermeterRecord = watermeterRecord;
	}
	public void setWsfRecord(WsfRecord wsfRecord) {
		this.wsfRecords.add(wsfRecord);
		this.wsfRecord = wsfRecord;
	}
	public void setHlfRecord(HlfRecord hlfRecord) {
		this.hlfRecords.add(hlfRecord);
		this.hlfRecord = hlfRecord;
	}
	public void setGlfRecord(GlfRecord glfRecord) {
		this.glfRecords.add(glfRecord);
		this.glfRecord = glfRecord;
	}
	public void setNqfRecord(NqfRecord nqfRecord) {
		this.nqfRecords.add(nqfRecord);
		this.nqfRecord = nqfRecord;
	}
	public void setOtherRecord(OtherRecord otherRecord) {
		this.otherRecords.add(otherRecord);
		this.otherRecord = otherRecord;
	}
	public void setFfRecord(FfRecord ffRecord) {
		this.ffRecords.add(ffRecord);
		this.ffRecord = ffRecord;
	}
	public String getPname() {
		return pname;
	}
	public void setPname(String pname) {
		this.pname = pname;
	}
	
}
